/* Author: Mark Mckillion, Chris Mowbray
 * Date: 17/04/2012
 * Version 1.0.*/

/* 
 * This is the frame that holds all the panels together.
 */


package assignment4;

import javax.swing.*;
import java.awt.*;
import javax.swing.border.LineBorder;

@SuppressWarnings("serial")
public class ModelFrame extends JFrame
{   // setting the panels to static so can be access directly
    public static DrawingPanel drawing = new DrawingPanel();
    public static JTextPane algoritm = new JTextPane();
     public static ControlPanel control = new ControlPanel();
    
    
    {
        setLayout(new BorderLayout());
        
        //program will stop running when "X" is pressed.
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
                
        //set the title for the program.
        this.setTitle("Sorting Program - Mark Mckillion & Chris Mowbray");
                
        //add the two frames to the frame show that they will show in the correct areas.
        this.add(drawing, BorderLayout.NORTH);
        this.add(control, BorderLayout.EAST);
        this.add(algoritm, BorderLayout.WEST);
        
        // giving the panesl borders
        drawing.setBorder(new LineBorder(Color.lightGray));
        control.setBorder(new LineBorder(Color.lightGray));
        algoritm.setBorder(new LineBorder(Color.lightGray));
        
        drawing.setBackground(Color.white);
        
        //set the size of the two panels.
        drawing.setPreferredSize(new Dimension(600,300));
        control.setPreferredSize(new Dimension(450,350));
        algoritm.setPreferredSize(new Dimension(600,365));
        
        algoritm.setText(" ");
        algoritm.setText(
         "public static void bubbleSort (int[] list)" + "\n" 
        + "  {"+ "\n"
        + "       int position, scan;"+ "\n"
        + "       int temp;"+ "\n"
        + "       for (position = list.length-1; position >= 0; position--)"+ "\n"
        + "        {"+ "\n"
        + "            for (scan = 0; scan <= position–1; scan++)"+ "\n"
        + "             {"+ "\n"
        + "                  if (list[scan+1] < list[scan])"+ "\n"
        + "                   {"+ "\n"
        + "                        temp = list[scan+1];"+ "\n"
        + "                        list[scan+1] = list[scan];"+ "\n"
        + "                        list[scan] = temp;"+ "\n"
        + "                   }"+ "\n"
        + "             }"+ "\n"
        + "        }"+ "\n"
        + "  }" + "\n"
        );
        

        
        // serring the font of the textpane.
        algoritm.setFont(new Font("Monospaced", Font.BOLD, 14));
        pack();
        setVisible(true);
    }
    
}   //End of ModelFrame class.